#include "TestButtom.h"
#include<QPushButton>
#include<QDebug>
#include<QVBoxLayout>
#include<QDialogButtonBox>
#include<QToolBar>
#include<QStatusBar>

TestButtom::TestButtom(QWidget *parent) : QWidget(parent)
{
    /*//1. 表单提交按钮,登录表单提交按钮
    QPushButton *btn1 = new QPushButton("Login", this);
    connect(btn1, &QPushButton::clicked, this, &TestButtom::slot_btn1_Clicked);

    //2 对话框操作按钮,确认对话框按钮
    QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
    buttonBox->addButton("OK", QDialogButtonBox::AcceptRole);
    buttonBox->addButton("Cancel", QDialogButtonBox::RejectRole);

    //3 工具栏操作按钮,工具栏按钮（带图标）
    QToolBar *toolbar = new QToolBar(this);
    QAction *saveAction = toolbar->addAction(QIcon(":/icons/save.png"), "Save");
    connect(saveAction, &QAction::triggered, this, &TestButtom::slot_saveDocument);
    */
    //1 ​​文本和图标显示
    QPushButton *btn1 = new QPushButton(this);
    btn1->setText("btn1");
    connect(btn1, &QPushButton::clicked, this, &TestButtom::slot_btn1_Clicked);
    QPushButton *btn1_2 = new QPushButton(this);
    btn1_2->setText("btn1_2");
    btn1_2->setIcon(QIcon(":/images/logo.png"));

    //2 设置工具提示,鼠标悬停到上面会出现提示信息
    QPushButton *btn2 = new QPushButton(this);
    btn2->setText("btn2");
    btn2 ->setToolTip("Click to perform action");

    //3 设置快捷键（Alt+C）
    QPushButton *btn3 = new QPushButton(this);
    btn3->setText("btn3");
    btn3->setShortcut(QKeySequence("Alt+C"));

    //4 设置状态提示（状态栏显示）
    QPushButton *btn4 = new QPushButton(this);
    btn4->setText("btn4");
    btn4->setStatusTip("Performs the main action");

    //5 设置快捷键（&b）
    QPushButton *btn5 = new QPushButton(this);
    btn5->setText("&btn5");
    btn5->setStatusTip("Performs the main action");


    QVBoxLayout *vlayou =new QVBoxLayout(this);
    vlayou->addWidget(btn1);
    vlayou->addWidget(btn1_2);
    vlayou->addWidget(btn2);
    vlayou->addWidget(btn3);
    vlayou->addWidget(btn4);
    vlayou->addWidget(btn5);



    //vlayou->addWidget(buttonBox);
    //vlayou->addWidget(toolbar);
}

void TestButtom::slot_btn1_Clicked()
{
    qDebug()<<"loging...";
}

void TestButtom::slot_saveDocument()
{
     qDebug()<<"saveDocument...";
}
